// ----------------------------------
// The Mod: Separate Act Stuff
// ----------------------------------

//Functions
reserve function GHZSetup_Act1SpeedUp
reserve function GHZSetup_Act1SlowDown
reserve function GHZSetup_Act2SpeedUp
reserve function GHZSetup_Act2SlowDown
reserve function GHZSetup_Act3SpeedUp
reserve function GHZSetup_Act3SlowDown

reserve function MZSetup_Act1SpeedUp
reserve function MZSetup_Act1SlowDown
reserve function MZSetup_Act2SpeedUp
reserve function MZSetup_Act2SlowDown
reserve function MZSetup_Act3SpeedUp
reserve function MZSetup_Act3SlowDown

reserve function SYZSetup_Act1SpeedUp
reserve function SYZSetup_Act1SlowDown
reserve function SYZSetup_Act2SpeedUp
reserve function SYZSetup_Act2SlowDown
reserve function SYZSetup_Act3SpeedUp
reserve function SYZSetup_Act3SlowDown

reserve function LZSetup_Act1SpeedUp
reserve function LZSetup_Act1SlowDown
reserve function LZSetup_Act2SpeedUp
reserve function LZSetup_Act2SlowDown
reserve function LZSetup_Act3SpeedUp
reserve function LZSetup_Act3SlowDown

reserve function SLZSetup_Act1SpeedUp
reserve function SLZSetup_Act1SlowDown
reserve function SLZSetup_Act2SpeedUp
reserve function SLZSetup_Act2SlowDown
reserve function SLZSetup_Act3SpeedUp
reserve function SLZSetup_Act3SlowDown

reserve function SBZSetup_Act1SpeedUp
reserve function SBZSetup_Act1SlowDown
reserve function SBZSetup_Act2SpeedUp
reserve function SBZSetup_Act2SlowDown
reserve function SBZSetup_Act3SpeedUp
reserve function SBZSetup_Act3SlowDown

function GHZSetup_Act1SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("GreenHill_F.ogg", 0, 0x7AA16, 0x1EF0)
			break
		case 2
			SetMusicTrack("GreenHill_F.ogg", 0, 0x7AA16)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("GreenHill_F.ogg", 0, 0x7AA16)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function GHZSetup_Act1SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("GreenHill.ogg", 0, 0x9B0AA, 0x316A)
			break
		case 2
			SetMusicTrack("GreenHill.ogg", 0, 0x9B0AA)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("GreenHill.ogg", 0, 0x9B0AA)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function

function GHZSetup_Act2SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SwapMusicTrack("GreenHill2_F.ogg", 0, 522540, 0x1F40)
			SwapMusicTrack("GreenHill2_F.ogg", 0, 522540, 0x1F40)
			break
		case 2
			SetMusicTrack("GreenHill2_F.ogg", 0, 522540)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		case 4
			SetMusicTrack("GreenHill2_F.ogg", 0, 522540)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function GHZSetup_Act2SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("GreenHill2.ogg", 0, 653175, 0x30D4)
			break
		case 2
			SetMusicTrack("GreenHill2.ogg", 0, 653175)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		case 4
			SetMusicTrack("GreenHill2.ogg", 0, 653175)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function

function GHZSetup_Act3SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("GreenHill3_F.ogg", 0, 3162125, 0x1F40)
			break
		case 2
			SetMusicTrack("GreenHill3_F.ogg", 0, 3162125)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		case 4
			SetMusicTrack("GreenHill3_F.ogg", 0, 3162125)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function GHZSetup_Act3SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("GreenHill3.ogg", 0, 3950428, 0x30D4)
			break
		case 2
			SetMusicTrack("GreenHill3.ogg", 0, 3950428)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		case 4
			SetMusicTrack("GreenHill3.ogg", 0, 3950428)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function MZSetup_Act1SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Marble_F.ogg", 0, 0x136B1, 0x1F40)
			break
		case 2
			SetMusicTrack("Marble_F.ogg", 0, 0x136B1)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Marble_F.ogg", 0, 0x136B1)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function MZSetup_Act1SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Marble.ogg", 0, 0x18434, 0x30D4)
			break
		case 2
			SetMusicTrack("Marble.ogg", 0, 0x18434)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Marble.ogg", 0, 0x18434)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function

function MZSetup_Act2SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Marble2_F.ogg", 0, 103506, 0x1F40)
			break
		case 2
			SetMusicTrack("Marble2_F.ogg", 0, 103506)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Marble2_F.ogg", 0, 103506)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function

function MZSetup_Act2SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Marble2.ogg", 0, 129382, 0x30D4)
			break
		case 2
			SetMusicTrack("Marble2.ogg", 0, 129382)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Marble2.ogg", 0, 129382)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function

function MZSetup_Act3SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Marble3_F.ogg", 0, 70866, 0x1F40)
			break
		case 2
			SetMusicTrack("Marble3_F.ogg", 0, 70866)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Marble3_F.ogg", 0, 70866)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function MZSetup_Act3SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Marble3.ogg", 0, 88582, 0x30D4)
			break
		case 2
			SetMusicTrack("Marble3.ogg", 0, 88582)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		case 4
			SetMusicTrack("Marble3.ogg", 0, 88582)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function SYZSetup_Act1SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("SpringYard_F.ogg", 0, 0x13CE8, 0x1F40)
			break
		case 2
			SetMusicTrack("SpringYard_F.ogg", 0, 0x13CE8)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("SpringYard_F.ogg", 0, 0x13CE8)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SYZSetup_Act1SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("SpringYard.ogg", 0, 0x18BF4, 0x30D4)
			break
		case 2
			SetMusicTrack("SpringYard.ogg", 0, 0x18BF4)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("SpringYard.ogg", 0, 0x18BF4)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function SYZSetup_Act2SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("SpringYard2_F.ogg", 0, 81634, 0x1F40)
			break
		case 2
			SetMusicTrack("SpringYard2_F.ogg", 0, 81634)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("SpringYard2_F.ogg", 0, 81634)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SYZSetup_Act2SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("SpringYard2.ogg", 0, 102042, 0x30D4)
			break
		case 2
			SetMusicTrack("SpringYard2.ogg", 0, 102042)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("SpringYard2.ogg", 0, 102042)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function

function SYZSetup_Act3SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("SpringYard3_F.ogg", 0, 1355136, 0x1F40)
			break
		case 2
			SetMusicTrack("SpringYard3_F.ogg", 0, 1355136)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("SpringYard3_F.ogg", 0, 1355136)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SYZSetup_Act3SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("SpringYard3.ogg", 0, 1693920, 0x30D4)
			break
		case 2
			SetMusicTrack("SpringYard3.ogg", 0, 1693920)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("SpringYard3.ogg", 0, 1693920)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function LZSetup_Act1SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Labyrinth_F.ogg", 0, 0x107D2, 0x1F40)
			break
		case 2
			SetMusicTrack("Labyrinth_F.ogg", 0, 0x107D2)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Labyrinth_F.ogg", 0, 0x107D2)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function LZSetup_Act1SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Labyrinth.ogg", 0, 0x149DC, 0x30D4)
			break
		case 2
			SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function LZSetup_Act2SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Labyrinth2_F.ogg", 0, 101396, 0x1F40)
			break
		case 2
			SetMusicTrack("Labyrinth2_F.ogg", 0, 101396)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Labyrinth2_F.ogg", 0, 101396)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function LZSetup_Act2SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Labyrinth2.ogg", 0, 126745, 0x30D4)
			break
		case 2
			SetMusicTrack("Labyrinth2.ogg", 0, 126745)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Labyrinth2.ogg", 0, 126745)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function

function LZSetup_Act3SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Labyrinth3_F.ogg", 0, 17336, 0x1F40)
			break
		case 2
			SetMusicTrack("Labyrinth3_F.ogg", 0, 17336)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Labyrinth3_F.ogg", 0, 17336)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function LZSetup_Act3SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Labyrinth3.ogg", 0, 21670, 0x30D4)
			break
		case 2
			SetMusicTrack("Labyrinth3.ogg", 0, 21670)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Labyrinth3.ogg", 0, 21670)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function SBZSetup_Act3SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("ScrapBrainGG_F.ogg", 0, 1, 0x1F40)
			break
		case 2
			SetMusicTrack("ScrapBrainGG_F.ogg", 0, 1)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("ScrapBrainGG_F.ogg", 0, 1)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SBZSetup_Act3SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("ScrapBrainGG.ogg", 0, 1, 0x30D4)
			break
		case 2
			SetMusicTrack("ScrapBrainGG.ogg", 0, 1)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("ScrapBrainGG.ogg", 0, 1)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function



function SLZSetup_Act1SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Starlight_F.ogg", 0, 0x10838, 0x1F40)
			break
		case 2
			SetMusicTrack("Starlight_F.ogg", 0, 0x10838)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Starlight_F.ogg", 0, 0x10838)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SLZSetup_Act1SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Starlight.ogg", 0, 0x1498C, 0x30D4)
			break
		case 2
			SetMusicTrack("Starlight.ogg", 0, 0x1498C)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Starlight.ogg", 0, 0x1498C)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function SLZSetup_Act2SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Starlight2_F.ogg", 0, 67492, 0x1F40)
			break
		case 2
			SetMusicTrack("Starlight2_F.ogg", 0, 67492)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Starlight2_F.ogg", 0, 67492)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SLZSetup_Act2SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Starlight2.ogg", 0, 84365, 0x30D4)
			break
		case 2
			SetMusicTrack("Starlight2.ogg", 0, 84365)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Starlight2.ogg", 0, 84365)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function

function SLZSetup_Act3SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Starlight3_F.ogg", 0, 999741, 0x1F40)
			break
		case 2
			SetMusicTrack("Starlight3_F.ogg", 0, 999741)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Starlight3_F.ogg", 0, 999741)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SLZSetup_Act3SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Starlight3.ogg", 0, 1249676, 0x30D4)
			break
		case 2
			SetMusicTrack("Starlight3.ogg", 0, 1249676)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Starlight3.ogg", 0, 1249676)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function SBZSetup_Act1SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("ScrapBrain_F.ogg", 0, 1, 0x1F40)
			break
		case 2
			SetMusicTrack("ScrapBrain_F.ogg", 0, 1)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("ScrapBrain_F.ogg", 0, 1)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SBZSetup_Act1SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("ScrapBrain.ogg", 0, 1, 0x30D4)
			break
		case 2
			SetMusicTrack("ScrapBrain.ogg", 0, 1)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("ScrapBrain.ogg", 0, 1)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break			
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function SBZSetup_Act2SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("ScrapBrain2_F.ogg", 0, 113322, 0x1F40)
			break
		case 2
			SetMusicTrack("ScrapBrain2_F.ogg", 0, 113322)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("ScrapBrain2_F.ogg", 0, 113322)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function SBZSetup_Act2SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("ScrapBrain2.ogg", 0, 141653, 0x30D4)
			break
		case 2
			SetMusicTrack("ScrapBrain2.ogg", 0, 141653)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("ScrapBrain2.ogg", 0, 141653)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


event ObjectMain
	CheckCurrentStageFolder("Zone01")
	if checkResult == 1
		switch stage.actNum
			default
				SetMusicTrack("GreenHill.ogg", 0, 0x9B0AA)
				SpeedUpMusic = GHZSetup_Act1SpeedUp
				SlowDownMusic = GHZSetup_Act1SlowDown
				break
			case 2
				SetMusicTrack("GreenHill2.ogg", 0, 653175)
				SpeedUpMusic = GHZSetup_Act2SpeedUp
				SlowDownMusic = GHZSetup_Act2SlowDown
				break
			case 3
				SetMusicTrack("GreenHill3.ogg", 0, 3950428)
				SpeedUpMusic = GHZSetup_Act3SpeedUp
				SlowDownMusic = GHZSetup_Act3SlowDown
				break
		end switch
	end if
	CheckCurrentStageFolder("Zone02")
	if checkResult == 1
		switch stage.actNum
			case 1
				SetMusicTrack("Marble.ogg", 0, 0x18434)
				SpeedUpMusic = MZSetup_Act1SpeedUp
				SlowDownMusic = MZSetup_Act1SlowDown
				break
			case 2
				SetMusicTrack("Marble2.ogg", 0, 129382)
				SpeedUpMusic = MZSetup_Act2SpeedUp
				SlowDownMusic = MZSetup_Act2SlowDown
				break
			case 3
				SetMusicTrack("Marble3.ogg", 0, 88582)
				SpeedUpMusic = MZSetup_Act3SpeedUp
				SlowDownMusic = MZSetup_Act3SlowDown
				break
		end switch	
	end if
	CheckCurrentStageFolder("Zone03")
	if checkResult == 1
		switch stage.actNum
			case 1
				SetMusicTrack("SpringYard.ogg", 0, 0x18BF4)
				SpeedUpMusic = SYZSetup_Act1SpeedUp
				SlowDownMusic = SYZSetup_Act1SlowDown
				break
			case 2
				SetMusicTrack("SpringYard2.ogg", 0, 102042)
				SpeedUpMusic = SYZSetup_Act2SpeedUp
				SlowDownMusic = SYZSetup_Act2SlowDown
				break
			case 3
				SetMusicTrack("SpringYard3.ogg", 0, 1693920)
				SpeedUpMusic = SYZSetup_Act3SpeedUp
				SlowDownMusic = SYZSetup_Act3SlowDown
				break
		end switch
	end if
	CheckCurrentStageFolder("Zone04")
	if checkResult == 1
		switch stage.actNum
			case 1
				SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
				SpeedUpMusic = LZSetup_Act1SpeedUp
				SlowDownMusic = LZSetup_Act1SlowDown
				break
			case 2
				SetMusicTrack("Labyrinth2.ogg", 0, 126745)
				SpeedUpMusic = LZSetup_Act2SpeedUp
				SlowDownMusic = LZSetup_Act2SlowDown
				break
			case 3
				SetMusicTrack("Labyrinth3.ogg", 0, 21670)
				SpeedUpMusic = LZSetup_Act3SpeedUp
				SlowDownMusic = LZSetup_Act3SlowDown
				break
			case 4
				SetMusicTrack("ScrapBrainGG.ogg", 0, 1)
				SpeedUpMusic = SBZSetup_Act3SpeedUp
				SlowDownMusic = SBZSetup_Act3SlowDown
				break
		end switch	
	end if
	CheckCurrentStageFolder("Zone05")
	if checkResult == 1	
		switch stage.actNum
			case 1
				SetMusicTrack("Starlight.ogg", 0, 0x1498C)
				SpeedUpMusic = SLZSetup_Act1SpeedUp
				SlowDownMusic = SLZSetup_Act1SlowDown
				break
			case 2
				SetMusicTrack("Starlight2.ogg", 0, 84365)
				SpeedUpMusic = SLZSetup_Act2SpeedUp
				SlowDownMusic = SLZSetup_Act2SlowDown
				break
			case 3
				SetMusicTrack("Starlight3.ogg", 0, 1249676)
				SpeedUpMusic = SLZSetup_Act3SpeedUp
				SlowDownMusic = SLZSetup_Act3SlowDown
				break
		end switch	
	end if
	CheckCurrentStageFolder("Zone06")
	if checkResult == 1	
		switch stage.actNum
			case 1
				SetMusicTrack("Starlight.ogg", 0, 0x1498C)
				SpeedUpMusic = SLZSetup_Act1SpeedUp
				SlowDownMusic = SLZSetup_Act1SlowDown
				break
			case 2
				SetMusicTrack("Starlight2.ogg", 0, 84365)
				SpeedUpMusic = SLZSetup_Act2SpeedUp
				SlowDownMusic = SLZSetup_Act2SlowDown
				break
			case 3
				SetMusicTrack("Starlight3.ogg", 0, 1249676)
				SpeedUpMusic = SLZSetup_Act3SpeedUp
				SlowDownMusic = SLZSetup_Act3SlowDown
				break
		end switch	
	end if	
	CheckCurrentStageFolder("Zone06")
	if checkResult == 1		
		switch stage.actNum
			case 1
				SetMusicTrack("ScrapBrain.ogg", 0, 1)
				SpeedUpMusic = SBZSetup_Act1SpeedUp
				SlowDownMusic = SBZSetup_Act1SlowDown
				break
			case 2
				SetMusicTrack("ScrapBrain2.ogg", 0, 141653)
				SpeedUpMusic = SBZSetup_Act2SpeedUp
				SlowDownMusic = SBZSetup_Act2SlowDown
				break
			case 5	
				SetMusicTrack("Final.ogg", 0, 0x14AC8)
				break
		end switch	
	end if
	
	object.value0++
	if object.value0 == 30
		object.type = TypeName[Blank Object]
	end if
end event


event ObjectDraw
end event


event ObjectStartup	
	object[997].type = TypeName[Act Music]
	object[997].priority = PRIORITY_ACTIVE_PAUSED
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
